#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Created: Tue May 18 19:15:48 2010

from sys import argv
from PyQt4 import QtCore, QtGui

class FrameAdvancedDiskManager(QtGui.QFrame):
    def __init__(self, connection, parent = None):
        super(FrameAdvancedDiskManager, self).__init__(parent)
        self.setupUi(self)
        
        self.connection = connection
        self.advancedDM = self.connection.root.Modules.DiskManagement.DiskManagement()
        
    def setupUi(self, advanced_disk_manager_frame):
        advanced_disk_manager_frame.setObjectName("advanced_disk_manager_frame")
        advanced_disk_manager_frame.resize(819, 580)
        advanced_disk_manager_frame.setGeometry(QtCore.QRect(210, 45, 831, 581))
        advanced_disk_manager_frame.setFrameShape(QtGui.QFrame.StyledPanel)
        advanced_disk_manager_frame.setFrameShadow(QtGui.QFrame.Raised)
        self.gridLayout_14 = QtGui.QGridLayout(advanced_disk_manager_frame)
        self.gridLayout_14.setObjectName("gridLayout_14")
        self.tabWidget = QtGui.QTabWidget(advanced_disk_manager_frame)
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtGui.QWidget()
        self.tab.setObjectName("tab")
        self.gridLayout_6 = QtGui.QGridLayout(self.tab)
        self.gridLayout_6.setObjectName("gridLayout_6")
        self.gridLayout = QtGui.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.btn_displayLVMInfo_2 = QtGui.QPushButton(self.tab)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("icons/edit-find.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_displayLVMInfo_2.setIcon(icon)
        self.btn_displayLVMInfo_2.setObjectName("btn_displayLVMInfo_2")
        self.gridLayout.addWidget(self.btn_displayLVMInfo_2, 0, 0, 1, 1)
        self.combo_lvmInfo_2 = QtGui.QComboBox(self.tab)
        self.combo_lvmInfo_2.setObjectName("combo_lvmInfo_2")
        self.combo_lvmInfo_2.addItem("")
        self.combo_lvmInfo_2.addItem("")
        self.combo_lvmInfo_2.addItem("")
        self.combo_lvmInfo_2.addItem("")
        self.gridLayout.addWidget(self.combo_lvmInfo_2, 0, 1, 1, 1)
        self.plain_lvmInfo_2 = QtGui.QTextEdit(self.tab)
        self.plain_lvmInfo_2.setObjectName("plain_lvmInfo_2")
        self.plain_lvmInfo_2.setFixedSize(500, 530)
        self.gridLayout.addWidget(self.plain_lvmInfo_2, 1, 0, 1, 2)
        self.gridLayout_6.addLayout(self.gridLayout, 0, 0, 4, 1)
        self.groupBox_29 = QtGui.QGroupBox(self.tab)
        self.groupBox_29.setObjectName("groupBox_29")
        self.gridLayout_2 = QtGui.QGridLayout(self.groupBox_29)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.label_59 = QtGui.QLabel(self.groupBox_29)
        self.label_59.setObjectName("label_59")
        self.gridLayout_2.addWidget(self.label_59, 0, 0, 1, 1)
        self.text_devPath_prepareLVM_2 = QtGui.QLineEdit(self.groupBox_29)
        self.text_devPath_prepareLVM_2.setObjectName("text_devPath_prepareLVM_2")
        self.gridLayout_2.addWidget(self.text_devPath_prepareLVM_2, 0, 1, 1, 1)
        self.label_60 = QtGui.QLabel(self.groupBox_29)
        self.label_60.setObjectName("label_60")
        self.gridLayout_2.addWidget(self.label_60, 1, 0, 1, 1)
        self.text_partNum_prepareLVM_2 = QtGui.QLineEdit(self.groupBox_29)
        self.text_partNum_prepareLVM_2.setObjectName("text_partNum_prepareLVM_2")
        self.gridLayout_2.addWidget(self.text_partNum_prepareLVM_2, 1, 1, 1, 1)
        self.label_61 = QtGui.QLabel(self.groupBox_29)
        self.label_61.setObjectName("label_61")
        self.gridLayout_2.addWidget(self.label_61, 2, 0, 1, 1)
        self.combo_lvmState_2 = QtGui.QComboBox(self.groupBox_29)
        self.combo_lvmState_2.setObjectName("combo_lvmState_2")
        self.combo_lvmState_2.addItem("")
        self.combo_lvmState_2.addItem("")
        self.combo_lvmState_2.addItem("")
        self.gridLayout_2.addWidget(self.combo_lvmState_2, 2, 1, 1, 1)
        self.btn_prepareLVM_2 = QtGui.QPushButton(self.groupBox_29)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap("icons/system-software-update.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_prepareLVM_2.setIcon(icon1)
        self.btn_prepareLVM_2.setObjectName("btn_prepareLVM_2")
        self.gridLayout_2.addWidget(self.btn_prepareLVM_2, 2, 2, 1, 1)
        self.gridLayout_6.addWidget(self.groupBox_29, 0, 1, 1, 1)
        self.groupBox_28 = QtGui.QGroupBox(self.tab)
        self.groupBox_28.setObjectName("groupBox_28")
        self.gridLayout_3 = QtGui.QGridLayout(self.groupBox_28)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.label_58 = QtGui.QLabel(self.groupBox_28)
        self.label_58.setObjectName("label_58")
        self.gridLayout_3.addWidget(self.label_58, 0, 0, 1, 1)
        self.text_createPV_2 = QtGui.QLineEdit(self.groupBox_28)
        self.text_createPV_2.setObjectName("text_createPV_2")
        self.gridLayout_3.addWidget(self.text_createPV_2, 0, 1, 1, 1)
        self.btn_createPV_2 = QtGui.QPushButton(self.groupBox_28)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap("icons/applications-development.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_createPV_2.setIcon(icon2)
        self.btn_createPV_2.setObjectName("btn_createPV_2")
        self.gridLayout_3.addWidget(self.btn_createPV_2, 0, 2, 1, 1)
        self.gridLayout_6.addWidget(self.groupBox_28, 1, 1, 1, 1)
        self.groupBox_30 = QtGui.QGroupBox(self.tab)
        self.groupBox_30.setObjectName("groupBox_30")
        self.gridLayout_4 = QtGui.QGridLayout(self.groupBox_30)
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.label_62 = QtGui.QLabel(self.groupBox_30)
        self.label_62.setObjectName("label_62")
        self.gridLayout_4.addWidget(self.label_62, 0, 0, 1, 1)
        self.text_vgName_2 = QtGui.QLineEdit(self.groupBox_30)
        self.text_vgName_2.setObjectName("text_vgName_2")
        self.gridLayout_4.addWidget(self.text_vgName_2, 0, 1, 1, 2)
        self.label_63 = QtGui.QLabel(self.groupBox_30)
        self.label_63.setObjectName("label_63")
        self.gridLayout_4.addWidget(self.label_63, 1, 0, 1, 1)
        self.text_pePartition_2 = QtGui.QLineEdit(self.groupBox_30)
        self.text_pePartition_2.setObjectName("text_pePartition_2")
        self.gridLayout_4.addWidget(self.text_pePartition_2, 1, 1, 1, 2)
        self.combo_createVGorAddPE_2 = QtGui.QComboBox(self.groupBox_30)
        self.combo_createVGorAddPE_2.setObjectName("combo_createVGorAddPE_2")
        self.combo_createVGorAddPE_2.addItem("")
        self.combo_createVGorAddPE_2.addItem("")
        self.combo_createVGorAddPE_2.addItem("")
        self.gridLayout_4.addWidget(self.combo_createVGorAddPE_2, 2, 0, 1, 2)
        self.btn_addPE_3 = QtGui.QPushButton(self.groupBox_30)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap("icons/applications-system.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_addPE_3.setIcon(icon3)
        self.btn_addPE_3.setObjectName("btn_addPE_3")
        self.gridLayout_4.addWidget(self.btn_addPE_3, 2, 2, 1, 1)
        self.gridLayout_6.addWidget(self.groupBox_30, 2, 1, 1, 1)
        self.groupBox_31 = QtGui.QGroupBox(self.tab)
        self.groupBox_31.setObjectName("groupBox_31")
        self.gridLayout_5 = QtGui.QGridLayout(self.groupBox_31)
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.label_64 = QtGui.QLabel(self.groupBox_31)
        self.label_64.setObjectName("label_64")
        self.gridLayout_5.addWidget(self.label_64, 0, 0, 1, 1)
        self.text_lvSize_2 = QtGui.QLineEdit(self.groupBox_31)
        self.text_lvSize_2.setObjectName("text_lvSize_2")
        self.gridLayout_5.addWidget(self.text_lvSize_2, 0, 1, 1, 1)
        self.label_65 = QtGui.QLabel(self.groupBox_31)
        self.label_65.setObjectName("label_65")
        self.gridLayout_5.addWidget(self.label_65, 1, 0, 1, 1)
        self.text_lvName_2 = QtGui.QLineEdit(self.groupBox_31)
        self.text_lvName_2.setObjectName("text_lvName_2")
        self.gridLayout_5.addWidget(self.text_lvName_2, 1, 1, 1, 1)
        self.label_66 = QtGui.QLabel(self.groupBox_31)
        self.label_66.setObjectName("label_66")
        self.gridLayout_5.addWidget(self.label_66, 2, 0, 1, 1)
        self.text_vgName_lvCreate_2 = QtGui.QLineEdit(self.groupBox_31)
        self.text_vgName_lvCreate_2.setObjectName("text_vgName_lvCreate_2")
        self.gridLayout_5.addWidget(self.text_vgName_lvCreate_2, 2, 1, 1, 1)
        self.btn_addPE_4 = QtGui.QPushButton(self.groupBox_31)
        self.btn_addPE_4.setIcon(icon2)
        self.btn_addPE_4.setObjectName("btn_addPE_4")
        self.gridLayout_5.addWidget(self.btn_addPE_4, 2, 2, 1, 1)
        self.gridLayout_6.addWidget(self.groupBox_31, 3, 1, 1, 1)
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtGui.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.gridLayout_13 = QtGui.QGridLayout(self.tab_2)
        self.gridLayout_13.setObjectName("gridLayout_13")
        self.gridLayout_12 = QtGui.QGridLayout()
        self.gridLayout_12.setObjectName("gridLayout_12")
        self.gridLayout_7 = QtGui.QGridLayout()
        self.gridLayout_7.setObjectName("gridLayout_7")
        self.btn_getRAIDDevInfo_2 = QtGui.QPushButton(self.tab_2)
        self.btn_getRAIDDevInfo_2.setIcon(icon)
        self.btn_getRAIDDevInfo_2.setObjectName("btn_getRAIDDevInfo_2")
        self.gridLayout_7.addWidget(self.btn_getRAIDDevInfo_2, 0, 0, 1, 1)
        self.label_52 = QtGui.QLabel(self.tab_2)
        self.label_52.setObjectName("label_52")
        self.gridLayout_7.addWidget(self.label_52, 0, 1, 1, 1)
        self.text_raidDeviceInfo_2 = QtGui.QLineEdit(self.tab_2)
        self.text_raidDeviceInfo_2.setObjectName("text_raidDeviceInfo_2")
        self.gridLayout_7.addWidget(self.text_raidDeviceInfo_2, 0, 2, 1, 1)
        self.plain_raidDeviceInfo_2 = QtGui.QTextEdit(self.tab_2)
        self.plain_raidDeviceInfo_2.setObjectName("plain_raidDeviceInfo_2")
        self.plain_raidDeviceInfo_2.setFixedSize(500, 530)
        self.gridLayout_7.addWidget(self.plain_raidDeviceInfo_2, 1, 0, 1, 3)
        self.gridLayout_12.addLayout(self.gridLayout_7, 0, 0, 4, 1)
        self.groupBox_27 = QtGui.QGroupBox(self.tab_2)
        self.groupBox_27.setObjectName("groupBox_27")
        self.gridLayout_8 = QtGui.QGridLayout(self.groupBox_27)
        self.gridLayout_8.setObjectName("gridLayout_8")
        self.label_55 = QtGui.QLabel(self.groupBox_27)
        self.label_55.setObjectName("label_55")
        self.gridLayout_8.addWidget(self.label_55, 0, 0, 1, 1)
        self.text_devPath_prepareRaid_2 = QtGui.QLineEdit(self.groupBox_27)
        self.text_devPath_prepareRaid_2.setObjectName("text_devPath_prepareRaid_2")
        self.gridLayout_8.addWidget(self.text_devPath_prepareRaid_2, 0, 1, 1, 1)
        self.label_56 = QtGui.QLabel(self.groupBox_27)
        self.label_56.setObjectName("label_56")
        self.gridLayout_8.addWidget(self.label_56, 1, 0, 1, 1)
        self.text_partNum_prepareRaid_2 = QtGui.QLineEdit(self.groupBox_27)
        self.text_partNum_prepareRaid_2.setObjectName("text_partNum_prepareRaid_2")
        self.gridLayout_8.addWidget(self.text_partNum_prepareRaid_2, 1, 1, 1, 1)
        self.label_57 = QtGui.QLabel(self.groupBox_27)
        self.label_57.setObjectName("label_57")
        self.gridLayout_8.addWidget(self.label_57, 2, 0, 1, 1)
        self.combo_raidState_2 = QtGui.QComboBox(self.groupBox_27)
        self.combo_raidState_2.setObjectName("combo_raidState_2")
        self.combo_raidState_2.addItem("")
        self.combo_raidState_2.addItem("")
        self.combo_raidState_2.addItem("")
        self.gridLayout_8.addWidget(self.combo_raidState_2, 2, 1, 1, 1)
        self.btn_prepareRaid_2 = QtGui.QPushButton(self.groupBox_27)
        self.btn_prepareRaid_2.setIcon(icon1)
        self.btn_prepareRaid_2.setObjectName("btn_prepareRaid_2")
        self.gridLayout_8.addWidget(self.btn_prepareRaid_2, 2, 2, 1, 1)
        self.gridLayout_12.addWidget(self.groupBox_27, 0, 1, 1, 1)
        self.groupBox_24 = QtGui.QGroupBox(self.tab_2)
        self.groupBox_24.setObjectName("groupBox_24")
        self.gridLayout_9 = QtGui.QGridLayout(self.groupBox_24)
        self.gridLayout_9.setObjectName("gridLayout_9")
        self.label_46 = QtGui.QLabel(self.groupBox_24)
        self.label_46.setObjectName("label_46")
        self.gridLayout_9.addWidget(self.label_46, 0, 0, 1, 1)
        self.text_raidDevice_3 = QtGui.QLineEdit(self.groupBox_24)
        self.text_raidDevice_3.setObjectName("text_raidDevice_3")
        self.gridLayout_9.addWidget(self.text_raidDevice_3, 0, 1, 1, 1)
        self.label_47 = QtGui.QLabel(self.groupBox_24)
        self.label_47.setObjectName("label_47")
        self.gridLayout_9.addWidget(self.label_47, 1, 0, 1, 1)
        self.text_devPath_raidLevel_2 = QtGui.QLineEdit(self.groupBox_24)
        self.text_devPath_raidLevel_2.setObjectName("text_devPath_raidLevel_2")
        self.gridLayout_9.addWidget(self.text_devPath_raidLevel_2, 1, 1, 1, 1)
        self.label_49 = QtGui.QLabel(self.groupBox_24)
        self.label_49.setObjectName("label_49")
        self.gridLayout_9.addWidget(self.label_49, 2, 0, 1, 1)
        self.text_devicesNumbers_2 = QtGui.QLineEdit(self.groupBox_24)
        self.text_devicesNumbers_2.setObjectName("text_devicesNumbers_2")
        self.gridLayout_9.addWidget(self.text_devicesNumbers_2, 2, 1, 1, 1)
        self.label_50 = QtGui.QLabel(self.groupBox_24)
        self.label_50.setObjectName("label_50")
        self.gridLayout_9.addWidget(self.label_50, 3, 0, 1, 1)
        self.text_partitionsforRaid_2 = QtGui.QLineEdit(self.groupBox_24)
        self.text_partitionsforRaid_2.setObjectName("text_partitionsforRaid_2")
        self.gridLayout_9.addWidget(self.text_partitionsforRaid_2, 3, 1, 1, 1)
        self.btn_creareRaidarray_2 = QtGui.QPushButton(self.groupBox_24)
        self.btn_creareRaidarray_2.setIcon(icon2)
        self.btn_creareRaidarray_2.setObjectName("btn_creareRaidarray_2")
        self.gridLayout_9.addWidget(self.btn_creareRaidarray_2, 3, 2, 1, 1)
        self.gridLayout_12.addWidget(self.groupBox_24, 1, 1, 1, 1)
        self.groupBox_26 = QtGui.QGroupBox(self.tab_2)
        self.groupBox_26.setObjectName("groupBox_26")
        self.gridLayout_10 = QtGui.QGridLayout(self.groupBox_26)
        self.gridLayout_10.setObjectName("gridLayout_10")
        self.label_53 = QtGui.QLabel(self.groupBox_26)
        self.label_53.setObjectName("label_53")
        self.gridLayout_10.addWidget(self.label_53, 0, 0, 1, 1)
        self.text_raidDevice_6 = QtGui.QLineEdit(self.groupBox_26)
        self.text_raidDevice_6.setObjectName("text_raidDevice_6")
        self.gridLayout_10.addWidget(self.text_raidDevice_6, 0, 1, 1, 1)
        self.label_54 = QtGui.QLabel(self.groupBox_26)
        self.label_54.setObjectName("label_54")
        self.gridLayout_10.addWidget(self.label_54, 1, 0, 1, 1)
        self.text_partitionaddtoRD_2 = QtGui.QLineEdit(self.groupBox_26)
        self.text_partitionaddtoRD_2.setObjectName("text_partitionaddtoRD_2")
        self.gridLayout_10.addWidget(self.text_partitionaddtoRD_2, 1, 1, 1, 1)
        self.combo_raidPartition_2 = QtGui.QComboBox(self.groupBox_26)
        self.combo_raidPartition_2.setObjectName("combo_raidPartition_2")
        self.combo_raidPartition_2.addItem("")
        self.combo_raidPartition_2.addItem("")
        self.combo_raidPartition_2.addItem("")
        self.gridLayout_10.addWidget(self.combo_raidPartition_2, 1, 2, 1, 1)
        self.btn_addRemoveRaidPart_2 = QtGui.QPushButton(self.groupBox_26)
        self.btn_addRemoveRaidPart_2.setIcon(icon1)
        self.btn_addRemoveRaidPart_2.setObjectName("btn_addRemoveRaidPart_2")
        self.gridLayout_10.addWidget(self.btn_addRemoveRaidPart_2, 1, 3, 1, 1)
        self.gridLayout_12.addWidget(self.groupBox_26, 2, 1, 1, 1)
        self.groupBox_25 = QtGui.QGroupBox(self.tab_2)
        self.groupBox_25.setObjectName("groupBox_25")
        self.gridLayout_11 = QtGui.QGridLayout(self.groupBox_25)
        self.gridLayout_11.setObjectName("gridLayout_11")
        self.label_51 = QtGui.QLabel(self.groupBox_25)
        self.label_51.setObjectName("label_51")
        self.gridLayout_11.addWidget(self.label_51, 0, 0, 1, 1)
        self.text_raidDevice_5 = QtGui.QLineEdit(self.groupBox_25)
        self.text_raidDevice_5.setObjectName("text_raidDevice_5")
        self.gridLayout_11.addWidget(self.text_raidDevice_5, 0, 1, 1, 1)
        self.btn_removeRaidarray_2 = QtGui.QPushButton(self.groupBox_25)
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap("icons/edit-bomb.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.btn_removeRaidarray_2.setIcon(icon4)
        self.btn_removeRaidarray_2.setObjectName("btn_removeRaidarray_2")
        self.gridLayout_11.addWidget(self.btn_removeRaidarray_2, 0, 2, 1, 1)
        self.gridLayout_12.addWidget(self.groupBox_25, 3, 1, 1, 1)
        self.gridLayout_13.addLayout(self.gridLayout_12, 0, 0, 1, 1)
        self.tabWidget.addTab(self.tab_2, "")
        self.gridLayout_14.addWidget(self.tabWidget, 0, 0, 1, 1)
        
        ########################## Signal Connections ##########################
        ## LVM
        self.connect(self.btn_displayLVMInfo_2, QtCore.SIGNAL('clicked()'), self.displayLVMInfo)
        self.connect(self.btn_prepareLVM_2 , QtCore.SIGNAL('clicked()'), self.prepareLVM)
        self.connect(self.btn_createPV_2 , QtCore.SIGNAL('clicked()'), self.createPV)
        self.connect(self.btn_addPE_3 , QtCore.SIGNAL('clicked()'), self.addPE)
        self.connect(self.btn_addPE_4 , QtCore.SIGNAL('clicked()'), self.createLV)
        ## RAID
        self.connect(self.btn_getRAIDDevInfo_2 , QtCore.SIGNAL('clicked()'), self.displayRAIDInfo)
        self.connect(self.btn_prepareRaid_2 , QtCore.SIGNAL('clicked()'), self.prepareRAID)
        self.connect(self.btn_creareRaidarray_2 , QtCore.SIGNAL('clicked()'), self.createRAIDPart)
        self.connect(self.btn_addRemoveRaidPart_2 , QtCore.SIGNAL('clicked()'), self.addRemoveRAIDPart)
        self.connect(self.btn_removeRaidarray_2 , QtCore.SIGNAL('clicked()'), self.removeRAIDArray)
        ########################################################################
        self.retranslateUi(advanced_disk_manager_frame)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(advanced_disk_manager_frame)

    def retranslateUi(self, advanced_disk_manager_frame):
        advanced_disk_manager_frame.setWindowTitle(QtGui.QApplication.translate("advanced_disk_manager_frame", "Frame", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_displayLVMInfo_2.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Display", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_lvmInfo_2.setItemText(0, QtGui.QApplication.translate("advanced_disk_manager_frame", "..", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_lvmInfo_2.setItemText(1, QtGui.QApplication.translate("advanced_disk_manager_frame", "Volume Groups", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_lvmInfo_2.setItemText(2, QtGui.QApplication.translate("advanced_disk_manager_frame", "Physical Volumes", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_lvmInfo_2.setItemText(3, QtGui.QApplication.translate("advanced_disk_manager_frame", "Logical Volumes", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox_29.setTitle(QtGui.QApplication.translate("advanced_disk_manager_frame", "Prepare LVM Partitions", None, QtGui.QApplication.UnicodeUTF8))
        self.label_59.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Device path", None, QtGui.QApplication.UnicodeUTF8))
        self.label_60.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Partition number", None, QtGui.QApplication.UnicodeUTF8))
        self.label_61.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "State", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_lvmState_2.setItemText(0, QtGui.QApplication.translate("advanced_disk_manager_frame", "..", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_lvmState_2.setItemText(1, QtGui.QApplication.translate("advanced_disk_manager_frame", "on", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_lvmState_2.setItemText(2, QtGui.QApplication.translate("advanced_disk_manager_frame", "off", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_prepareLVM_2.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Prepare", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox_28.setTitle(QtGui.QApplication.translate("advanced_disk_manager_frame", "Create Physical Volumes", None, QtGui.QApplication.UnicodeUTF8))
        self.label_58.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "LVM partition", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_createPV_2.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Create", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox_30.setTitle(QtGui.QApplication.translate("advanced_disk_manager_frame", "Create Initial Volume Group and add PEs", None, QtGui.QApplication.UnicodeUTF8))
        self.label_62.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Volume group name", None, QtGui.QApplication.UnicodeUTF8))
        self.label_63.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Physical extended partition", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_createVGorAddPE_2.setItemText(0, QtGui.QApplication.translate("advanced_disk_manager_frame", "..", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_createVGorAddPE_2.setItemText(1, QtGui.QApplication.translate("advanced_disk_manager_frame", "Create volume group", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_createVGorAddPE_2.setItemText(2, QtGui.QApplication.translate("advanced_disk_manager_frame", "Add physical extended", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_addPE_3.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Add", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox_31.setTitle(QtGui.QApplication.translate("advanced_disk_manager_frame", "Create Logical Volumes", None, QtGui.QApplication.UnicodeUTF8))
        self.label_64.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Logical volume size", None, QtGui.QApplication.UnicodeUTF8))
        self.label_65.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Logical volume name", None, QtGui.QApplication.UnicodeUTF8))
        self.label_66.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Volume group name", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_addPE_4.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Create", None, QtGui.QApplication.UnicodeUTF8))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("advanced_disk_manager_frame", "Logical Volume Management", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_getRAIDDevInfo_2.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Display", None, QtGui.QApplication.UnicodeUTF8))
        self.label_52.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "RAID device", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox_27.setTitle(QtGui.QApplication.translate("advanced_disk_manager_frame", "Prepare RAID Partitions", None, QtGui.QApplication.UnicodeUTF8))
        self.label_55.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Device path", None, QtGui.QApplication.UnicodeUTF8))
        self.label_56.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Partition number", None, QtGui.QApplication.UnicodeUTF8))
        self.label_57.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "State", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_raidState_2.setItemText(0, QtGui.QApplication.translate("advanced_disk_manager_frame", "..", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_raidState_2.setItemText(1, QtGui.QApplication.translate("advanced_disk_manager_frame", "on", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_raidState_2.setItemText(2, QtGui.QApplication.translate("advanced_disk_manager_frame", "off", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_prepareRaid_2.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Prepare", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox_24.setTitle(QtGui.QApplication.translate("advanced_disk_manager_frame", "Create RAID Partitions", None, QtGui.QApplication.UnicodeUTF8))
        self.label_46.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "RAID device", None, QtGui.QApplication.UnicodeUTF8))
        self.label_47.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "RAID level", None, QtGui.QApplication.UnicodeUTF8))
        self.label_49.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Devices number", None, QtGui.QApplication.UnicodeUTF8))
        self.label_50.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Partitions", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_creareRaidarray_2.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Create", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox_26.setTitle(QtGui.QApplication.translate("advanced_disk_manager_frame", "Add/Remove partitions to/from RAID array", None, QtGui.QApplication.UnicodeUTF8))
        self.label_53.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "RAID device", None, QtGui.QApplication.UnicodeUTF8))
        self.label_54.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Partition", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_raidPartition_2.setItemText(0, QtGui.QApplication.translate("advanced_disk_manager_frame", "..", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_raidPartition_2.setItemText(1, QtGui.QApplication.translate("advanced_disk_manager_frame", "add", None, QtGui.QApplication.UnicodeUTF8))
        self.combo_raidPartition_2.setItemText(2, QtGui.QApplication.translate("advanced_disk_manager_frame", "remove", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_addRemoveRaidPart_2.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Hit", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox_25.setTitle(QtGui.QApplication.translate("advanced_disk_manager_frame", "Delete RAID array", None, QtGui.QApplication.UnicodeUTF8))
        self.label_51.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "RAID device", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_removeRaidarray_2.setText(QtGui.QApplication.translate("advanced_disk_manager_frame", "Delete", None, QtGui.QApplication.UnicodeUTF8))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtGui.QApplication.translate("advanced_disk_manager_frame", "Redundant array of independent disks", None, QtGui.QApplication.UnicodeUTF8))
        # set the tool tips for lvm tap
        self.text_devPath_prepareLVM_2.setToolTip(QtGui.QApplication.translate("Form", "pass the device pass .Example : Device path --> /dev/hda", None, QtGui.QApplication.UnicodeUTF8))
        self.text_partNum_prepareLVM_2.setToolTip(QtGui.QApplication.translate("Form", "pass the number of the partition.", None, QtGui.QApplication.UnicodeUTF8))
        self.text_createPV_2.setToolTip(QtGui.QApplication.translate("Form", "pass the lvm prepared partition Example: /dev/hda1 \n or if you want to create more than \n one partition you can pass it as --> /dev/hda1 /dev/hda2 ", None, QtGui.QApplication.UnicodeUTF8))
        self.text_vgName_2.setToolTip(QtGui.QApplication.translate("Form", "pass the volume group name", None, QtGui.QApplication.UnicodeUTF8))
        self.text_pePartition_2.setToolTip(QtGui.QApplication.translate("Form", "pass the physical extended prepared partition Example: /dev/hda1 \n or if you want to create more than \n one partition you can pass it as --> /dev/hda1 /dev/hda2", None, QtGui.QApplication.UnicodeUTF8))
        self.text_lvSize_2.setToolTip(QtGui.QApplication.translate("Form", "pass the size of the logical volume you want to create in migabytes", None, QtGui.QApplication.UnicodeUTF8))
        self.text_lvName_2.setToolTip(QtGui.QApplication.translate("Form", "pass the logical volume name", None, QtGui.QApplication.UnicodeUTF8))
        self.text_vgName_lvCreate_2.setToolTip(QtGui.QApplication.translate("Form", "pass the volume group name", None, QtGui.QApplication.UnicodeUTF8))
        # set the tool tips for raid tap
        self.text_raidDeviceInfo_2.setToolTip(QtGui.QApplication.translate("Form", "pass the raid device path . Example : /dev/md0", None, QtGui.QApplication.UnicodeUTF8))
        self.text_devPath_prepareRaid_2.setToolTip(QtGui.QApplication.translate("Form", "pass the device path _[for example /dev/hdc]_  ", None, QtGui.QApplication.UnicodeUTF8))
        self.text_partNum_prepareRaid_2.setToolTip(QtGui.QApplication.translate("Form", "pass the number of the partition you want to ser raid flag on it", None, QtGui.QApplication.UnicodeUTF8))
        self.text_raidDevice_3.setToolTip(QtGui.QApplication.translate("Form", "pass the raid device path . Example : /dev/md0", None, QtGui.QApplication.UnicodeUTF8))
        self.text_devPath_raidLevel_2.setToolTip(QtGui.QApplication.translate("Form", "pass the raid level", None, QtGui.QApplication.UnicodeUTF8))
        self.text_devicesNumbers_2.setToolTip(QtGui.QApplication.translate("Form", "pass the number of devices you want to add them to the raid array", None, QtGui.QApplication.UnicodeUTF8))
        self.text_partitionsforRaid_2.setToolTip(QtGui.QApplication.translate("Form", "pass the partitions you want to add to the raid array. Example = if you want to create more than \n one partition you can pass it as --> /dev/hda1 /dev/hda2", None, QtGui.QApplication.UnicodeUTF8))
        self.text_raidDevice_6.setToolTip(QtGui.QApplication.translate("Form", "pass the the raid device Example : /dev/md0", None, QtGui.QApplication.UnicodeUTF8))
        self.text_partitionaddtoRD_2.setToolTip(QtGui.QApplication.translate("Form", "pass the partition you want to add or remove from the raid array", None, QtGui.QApplication.UnicodeUTF8))
        self.text_raidDevice_5.setToolTip(QtGui.QApplication.translate("Form", "pass the raid device path you want to delete. Example : /dev/md0", None, QtGui.QApplication.UnicodeUTF8))
        
        
        
    #####################################################################
    ##################### LVM Operations ################################
    #####################################################################
    def displayLVMInfo(self):
        """
        displayLVMInfo(self)
            display info about Volum groups , Physical volumes or Logical volumes
        """
        current = str(self.combo_lvmInfo_2.currentText())
        if current == "Volume Groups":
            displayVG = str(self.advancedDM.display(VGDisplay=current))
            self.plain_lvmInfo_2.setText(displayVG)
            
        elif current == "Physical Volumes":
            displayPV = str(self.advancedDM.display(PVDisplay=current))
            self.plain_lvmInfo_2.setText(displayPV)
            
        elif current == "Logical Volumes":
            displayLV = str(self.advancedDM.display(LVDisplay=current))
            self.plain_lvmInfo_2.setText(displayLV)
    
    
    def prepareLVM(self):
        """
        prepareLVM(self)
            prepare lvm partitions by entering 3 fields:
                * the device path such as : /dev/sdb
                * the part number : 1,2,...
                * the part state : choose on/off
        """
        devPath = str(self.text_devPath_prepareLVM_2.text())
        partNumber = str(self.text_partNum_prepareLVM_2.text())
        current = str(self.combo_lvmState_2.currentText())
        if (devPath != "") and (partNumber != "") and (current != ".."):
            if self.advancedDM.prepareLVMPartition(devicePath=devPath , partNumber=partNumber , state=current):
                QtGui.QMessageBox.information(self, "Information" , "LVM partition successfully prepared")
                self.text_devPath_prepareLVM_2.clear()
                self.text_partNum_prepareLVM_2.clear()
            else:
                QtGui.QMessageBox.critical(self, "Exception", "Can't prepare LVM partition")
        else:
            QtGui.QMessageBox.critical(self, "Exception", "complete required fields")
    
    
    def createPV(self):
        """
        createPV(self)
            create volume groups by passing the lvm prepared partition
        """
        lvmPart = str(self.text_createPV_2.text())
        if (lvmPart != ""):
            if self.advancedDM.createPhysicalVolumes(LVMPart=lvmPart):
                QtGui.QMessageBox.information(self, "Information" , "Physical volume created successfully")
                self.text_createPV_2.clear()
            else:
                QtGui.QMessageBox.critical(self, "Exception", "Failed to create physical volume")
        else:
            QtGui.QMessageBox.critical(self, "Exception", "complete required fields")

    
    def addPE(self):
        """
        addPE(self)
            this function simulate two functions 
            1. create volume group
            2. add physical extended to an exist volum group 
        """
        vgName = str(self.text_vgName_2.text())
        pePart = str(self.text_pePartition_2.text())
        current = str(self.combo_createVGorAddPE_2.currentText())
        if (vgName != "") and (pePart != ""):
            if (current == "Create volume group"):
                if self.advancedDM.createInitialVolumGroup(VGName=vgName , PEPartition=pePart):
                    QtGui.QMessageBox.information(self, "Information" , "volum group created successfully")
                    self.text_vgName_2.clear()
                    self.text_pePartition_2.clear()
                else:
                    QtGui.QMessageBox.critical(self, "Exception", "failed to create volum group")
            
            elif (current == "Add physical extended"):
                if self.advancedDM.addPEtoVolumGroup(VGName=vgName , PEPartition=pePart):
                    QtGui.QMessageBox.information(self, "Information" , "physical extednded is added successfully")
                    self.text_vgName_2.clear()
                    self.text_pePartition_2.clear()
                else:
                    QtGui.QMessageBox.critical(self, "Exception", "failed to add physical extended to volum group")
                    self.text_vgName_2.clear()
                    self.text_pePartition_2.clear()
            
            else:
                QtGui.QMessageBox.critical(self, "Exception", "choose to create VG or to add PE")
        else:
            QtGui.QMessageBox.critical(self, "Exception", "complete required fields")
    
    
    def createLV(self):
        """
        createLV(self)
            create logical volumes.
        """
        lvSize = str(self.text_lvSize_2.text())
        lvName = str(self.text_lvName_2.text())
        vgName = str(self.text_vgName_lvCreate_2.text())
        if (lvSize != "") and (lvName != "") and (vgName != ""):
            if self.advancedDM.createLogicalVolum(size=lvSize , LVName=lvName , VGName=vgName):
                QtGui.QMessageBox.information(self, "Information" , "logical volum created successfully")
                self.text_lvSize_2.clear()
                self.text_lvName_2.clear()
                self.text_vgName_lvCreate_2.clear()
            else:
                QtGui.QMessageBox.critical(self, "Exception", "failed to create logical volum")
                self.text_lvSize_2.clear()
                self.text_lvName_2.clear()
                self.text_vgName_lvCreate_2.clear()
        else:
            QtGui.QMessageBox.critical(self, "Exception", "complete required fields")

    ######################################################################
    ########################## RAID Operations ###########################
    ######################################################################
    def displayRAIDInfo(self):
        RAIDDev = str(self.text_raidDeviceInfo_2.text())
        if (RAIDDev !=""):
            devInfo = self.advancedDM.getRAIDInfo(raidDevice=RAIDDev)
            self.plain_raidDeviceInfo_2.setText(devInfo)
            self.text_raidDeviceInfo_2.clear()
        else:
            QtGui.QMessageBox.critical(self, "Exception", "you must pass the raid device")
                
        
    def prepareRAID(self):
        devPath = str(self.text_devPath_prepareRaid_2.text())
        partNumber = str(self.text_partNum_prepareRaid_2.text())
        current = str(self.combo_raidState_2.currentText())
        if (devPath != "") and (partNumber != "") and (current != ".."):
            if self.advancedDM.prepareRAIDPartition(devicePath=devPath ,partNumber=partNumber, state=current):
                QtGui.QMessageBox.information(self, "Information" , "RAID partition prepared successfully")
                self.text_devPath_prepareRaid_2.clear()
                self.text_partNum_prepareRaid_2.clear()
            else:
                QtGui.QMessageBox.critical(self, "Exception", "Failed to prepare RAID partition")
        else:
            QtGui.QMessageBox.critical(self, "Exception", "complete required fields")
        
        
    def createRAIDPart(self):
        raidDev = str(self.text_raidDevice_3.text())
        raidLevel = str(self.text_devPath_raidLevel_2.text())
        devNumber = str(self.text_devicesNumbers_2.text())
        partitions = str(self.text_partitionsforRaid_2.text())
        if (raidDev != "") and (raidLevel != "") and (devNumber != "") and (partitions != ""):
            if self.advancedDM.createRAIDPartitons(raidDevice=raidDev ,level=raidLevel ,RAIDDevicesNumber=devNumber ,partitions=partitions):
                QtGui.QMessageBox.information(self, "Information" , "RAID partition(s) created successfully")
                self.text_raidDevice_3.clear()
                self.text_devPath_raidLevel_2.clear()
                self.text_devicesNumbers_2.clear()
                self.text_partitionsforRaid_2.clear()
            else:
                QtGui.QMessageBox.critical(self, "Exception", "Failed to create RAID partition(s)")
        else:
            QtGui.QMessageBox.critical(self, "Exception", "complete required fields")
        
        
    def addRemoveRAIDPart(self):
        current = str(self.combo_raidPartition_2.currentText())
        devRaid = str(self.text_raidDevice_6.text())
        partToAddOrRemove = str(self.text_partitionaddtoRD_2.text())
        if (current == "add"):
            if self.advancedDM.addPartitionsToRaidArray(raidDevice=devRaid ,partition=partToAddOrRemove):
                QtGui.QMessageBox.information(self, "Information" , "partition added successfully to Raid array")
                self.text_raidDevice_6.clear()
                self.text_partitionaddtoRD_2.clear()
            else:
                QtGui.QMessageBox.critical(self, "Exception", "Failed to add the partition to RAID array")
        
        elif (current == "remove"):
            if self.advancedDM.removePartitonFromRaidArray(raidDevice=devRaid ,partition=partToAddOrRemove):
                QtGui.QMessageBox.information(self, "Information" , "partition added successfully to Raid array")
                self.text_raidDevice_6.clear()
                self.text_partitionaddtoRD_2.clear()
            else:
                QtGui.QMessageBox.critical(self, "Exception", "Failed to remove the partition from RAID array")
        else:
            QtGui.QMessageBox.critical(self, "Exception", "complete required fields")
        
        
    def removeRAIDArray(self):
        devRaid = str(self.text_raidDevice_5.text())
        if (devRaid != ""):
            if self.advancedDM.stopRaidArray(raidDevice=devRaid):
                QtGui.QMessageBox.information(self, "Information" , "RAID array removed successfully")
                self.text_raidDevice_5.clear()
            else:
                QtGui.QMessageBox.critical(self, "Exception", "Failed to remove RAID array")
        else:
            QtGui.QMessageBox.critical(self, "Exception", "you must pass the raid device")

    
if __name__ == '__main__':
    app = QtGui.QApplication(argv)
    abstract_window = FrameAdvancedDiskManager()
    abstract_window.show()
    app.exec_()
